<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--表单组件-->
      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
        width="800px"
      >
        <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="150px">
          <el-form-item label="储罐区名称" prop="storageAreaName">
            <el-input v-model="form.storageAreaName" />
          </el-form-item>
          <el-form-item label="储存物名称">
            <el-input v-model="form.storageThingName" />
          </el-form-item>
          <el-form-item label="储存量">
            <el-input v-model="form.storageNumbeer" />
          </el-form-item>
          <el-form-item label="防护堤面积">
            <el-input v-model="form.protectiveDikeArea" />
          </el-form-item>
          <el-form-item label="储罐数">
            <el-input v-model="form.storageJarNumber" />
          </el-form-item>
          <el-form-item label="储罐间距">
            <el-input v-model="form.storageJarSpace" />
          </el-form-item>
          <el-form-item label="储罐序号">
            <el-input v-model="form.storageJarSerialNumber" />
          </el-form-item>
          <el-form-item label="储罐名">
            <el-input v-model="form.storageJarName" />
          </el-form-item>
          <el-form-item label="储罐形式">
            <el-input v-model="form.storageJarModel" />
          </el-form-item>
          <el-form-item label="储罐材质">
            <el-input v-model="form.storageJarMaterial" />
          </el-form-item>
          <el-form-item label="储罐压力">
            <el-input v-model="form.storageJarPressure" />
          </el-form-item>
          <el-form-item label="审核周期">
            <el-input v-model="form.auditCycle" />
          </el-form-item>
          <el-form-item label="火灾等级">
            <el-input v-model="form.fireClass" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="tableData"
        size="small"
        style="width: 100%;"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="storageAreaName" label="储罐区名称" />
        <el-table-column prop="storageThingName" label="储存物名称" />
        <el-table-column prop="storageNumbeer" label="储存量" />
        <el-table-column prop="protectiveDikeArea" label="防护堤面积" />
        <el-table-column prop="storageJarNumber" label="储罐数" />
        <el-table-column prop="storageJarSpace" label="储罐间距" />
        <el-table-column prop="storageJarSerialNumber" label="储罐序号" />
        <el-table-column prop="storageJarName" label="储罐名" />
        <el-table-column prop="storageJarModel" label="储罐形式" />
        <el-table-column prop="storageJarMaterial" label="储罐材质" />
        <el-table-column prop="storageJarPressure" label="储罐压力" />
        <el-table-column prop="auditCycle" label="审核周期" />
        <el-table-column prop="fireClass" label="火灾等级" />
        <el-table-column
          v-permission="['admin','storageAreaManage:edit','storageAreaManage:del']"
          label="操作"
          width="150px"
          align="center"
        >
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />

          </template>

        </el-table-column>
      </el-table>

    </div>
  </div>
</template>

<script>
import crudStorageAreaManage from '@/api/mhm/storageAreaManage'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { get } from '@/api/mhm/storageAreaManage'

const defaultForm = {
  id: null,
  createTime: null,
  updateTime: null,
  createBy: null,
  updateBy: null,
  storageAreaName: null,
  storageThingName: null,
  storageNumbeer: null,
  protectiveDikeArea: null,
  storageJarNumber: null,
  storageJarSpace: null,
  storageJarSerialNumber: null,
  storageJarName: null,
  storageJarModel: null,
  storageJarMaterial: null,
  storageJarPressure: null,
  auditCycle: null,
  fireClass: null
}
export default {
  name: 'StorageAreaManage',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm)],
  cruds() {
    return CRUD({
      title: '储罐区管理',
      url: 'api/storageAreaManage',
      sort: 'id,desc',
      crudMethod: { ...crudStorageAreaManage }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'storageAreaManage:add'],
        edit: ['admin', 'storageAreaManage:edit'],
        del: ['admin', 'storageAreaManage:del']
      },
      tableData: [],
      rules: {
        storageAreaName: {
          required: true, message: '请输入储罐区名称', trigger: 'blur'
        }
      },
      queryTypeOptions: [
        { key: 'storageAreaName', display_name: '储罐区名称' }
      ]
    }
  },
  created() {
    const id = this.$route.query.storageAreaManageId
    console.log(id)
    get(id).then(res => {
      this.tableData = res.content
    })
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }

  }
}
</script>

<style scoped>

</style>
